package com.dge.app.common;

import com.dge.app.MyApplication;
import ohos.app.Context;
import ohos.data.DatabaseHelper;
import ohos.data.preferences.Preferences;

public class UserInfoMgr {
    public static String firstInKey = "firstIn";
    public static String functionData = "[\"一场仗\",\"目标任务\",\"重点项目\",\"成果晾晒\",\"比学赶超\",\"揭榜挂帅\",\"督办圈阅\",\"超时亮灯\",\"一表通\"]";
    public static String statisticsData = "{\"urls\":[\"/overview_preview_home\",\"/overview_preview_home\"],\"names\":[\"记账方案 - 任务板\",\"记账方案 - 任务板\"]}";
    private static Preferences preferences;

    public static void init() {
        DatabaseHelper databaseHelper = new DatabaseHelper(MyApplication.context);
        preferences = databaseHelper.getPreferences(firstInKey);
        loadUserInfo();
    }

    public static void loadUserInfo() {
        functionData = preferences.getString(Constants.PREF_KEY_STATISTIC_DATA, functionData);
        statisticsData = preferences.getString(Constants.PREF_KEY_FUNC_DATA, statisticsData);
    }

    public static void saveUserInfo() {
        preferences.putString(Constants.PREF_KEY_FUNC_DATA, statisticsData);
        preferences.putString(Constants.PREF_KEY_STATISTIC_DATA, functionData);
    }

    public static void clearUserInfo() {
        preferences.clear();
    }
}